home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-22 | 2.0 KB | 87 lines | [TEXT/KAHL] |
- // Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
-
- #include "mtb.h"
-
- void CreateTrackMatte (Track theTrack)
- {
- QDErr err;
- GWorldPtr aGW;
- Rect trackBox;
- Fixed trackHeight;
- Fixed trackWidth;
- CTabHandle grayCTab;
-
- GetTrackDimensions (theTrack, &trackWidth, &trackHeight);
- SetRect (&trackBox, 0, 0, FixRound (trackWidth),
- FixRound (trackHeight));
-
- grayCTab = GetCTable(40); // 8 bit + 32 = 8 bit gray
- err = NewGWorld (&aGW, 8, &trackBox, grayCTab,
- (GDHandle) nil, 0);
- DisposeCTable (grayCTab);
- if (!err && (aGW != nil)) {
- SetTrackMatte (theTrack, aGW->portPixMap);
- DisposeGWorld (aGW);
- }
- }
-
- void UpdateTrackMatte (Track theTrack)
- {
- OSErr err;
- PixMapHandle trackMatte;
- PixMapHandle savePortPix;
- Movie theMovie;
- GWorldPtr tempGW;
- CGrafPtr savePort;
- GDHandle saveGDevice;
- Rect matteBox;
- short i;
-
- theMovie = GetTrackMovie (theTrack);
- trackMatte = GetTrackMatte (theTrack);
- if (trackMatte == nil) {
- // track doesn't have a matte, so give it one
- CreateTrackMatte (theTrack);
- trackMatte = GetTrackMatte (theTrack);
- if (trackMatte == nil)
- return;
- }
-
- GetGWorld (&savePort, &saveGDevice);
- matteBox = (**trackMatte).bounds;
- err = NewGWorld(&tempGW,
- (**trackMatte).pixelSize, &matteBox,
- (**trackMatte).pmTable, (GDHandle) nil, 0);
- if (err || (tempGW == nil)) return;
-
- SetGWorld (tempGW, nil);
- savePortPix = tempGW->portPixMap;
- LockPixels (trackMatte);
- SetPortPix (trackMatte);
-
- // draw a gray ramp rectangle around the edge of the matte
- for (i = 0; i < 35; i++) {
- RGBColor aColor;
- long tempLong;
-
- tempLong = 65536 - ((65536 / 35) * (long)i);
- aColor.red = aColor.green = aColor.blue = tempLong;
- RGBForeColor(&aColor);
- FrameRect (&matteBox);
- InsetRect (&matteBox, 1, 1);
- }
-
- // fill the center of the matte with black
- ForeColor (blackColor);
- PaintRect (&matteBox);
-
- SetPortPix (savePortPix);
- SetGWorld (savePort, saveGDevice);
- DisposeGWorld (tempGW);
-
- UnlockPixels (trackMatte);
- SetTrackMatte (theTrack, trackMatte);
-
- DisposeMatte (trackMatte);
- }
-